import {
  brandListApi,
  seriesListApi,
  productListApi,
  collectionApi,
  cancelCollectionApi,
  collectionListApi,
  batchDeleteApi,
  searchListApi,
  searchCabinetListApi,
} from '../api/wikiApi';

/**
 *
 * @param data brandName 品牌名称
 * @param data countryOfOrigin 系列名称 1 = 国产，2 = 古巴，3 =  非古巴
 *
 * @returns
 */

export const brandListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    brandListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 *
 * @param data brandId 品牌名称
 *
 * @returns
 */

export const seriesListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    seriesListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 *
 * @param data sku 产品sku
 * @returns
 */

export const productListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    productListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};
/**
 * 收藏雪茄
 * @param data sku 产品sku
 * @returns
 */
export const collectionFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    collectionApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 * 取消收藏雪茄
 * @param data sku 产品sku
 * @returns
 */
export const cancelCollectionFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    cancelCollectionApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 * 批量取消收藏雪茄
 * @param data collectSkus 收藏sku列表
 * @param data ucUserId 用户中心userId
 * @returns
 */
export const batchDeleteFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    batchDeleteApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 * 取消收藏雪茄
 * @param data sku 产品sku
 * @returns
 */
export const collectionListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    collectionListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 * 根据名称搜索雪茄产品列表
 * @param data sku 产品sku
 * @returns
 */
export const searchListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    searchListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};

/**
 * 根据名称搜索雪茄柜产品列表
 * @param data sku 产品sku
 * @returns
 */
export const searchCabinetListFun = async (data: any = {}) => {
  return new Promise((reslve: any, reject: any) => {
    searchCabinetListApi(data)
      .then((res: any) => {
        reslve(res.data);
      })
      .catch((e: any) => {
        reject(e);
      });
  });
};
